<?php
namespace app\model\store;

use think\Db;

class Product
{
    //获取商家商品列表
    public function product_lists($where,$limit,$order,$db_i)
    {
        $lists = Db::name('product_'.$db_i)->field('id,title,now_price,all_num-now_num as s_kucun,pfen,status,from_unixtime(upd_time) as upd_time')->where($where)->where('status','<',3)->order($order)->paginate($limit);
        return $lists;
    }

    //增加商家商品
    public function product_add($data,$db_i)
    {
        $status = Db::name('product_'.$db_i)->insert($data);
        return $status;
    }

    //修改商户商品信息
    public function product_update($where,$data,$db_i)
    {
        $status = Db::name('product_'.$db_i)->where($where)->where('status','<',3)->update($data);
        return $status;
    }

    //获取商家商品分组列表
    public function product_group_lists($where,$limit,$order,$db_i)
    {
        $lists = Db::name('pcolumn_'.$db_i)->field('id,title,wid,status,from_unixtime(upd_time) as upd_time')->where($where)->where('status','<',3)->order($order)->paginate($limit);
        return $lists;
    }

    //修改商户商品分组信息
    public function product_group_update($where,$data,$db_i)
    {
        $status = Db::name('pcolumn_'.$db_i)->where($where)->where('status','<',3)->update($data);
        return $status;
    }

    //获取商家商品分组列表(所有)
    public function product_group_lists_all($id,$db_i)
    {
        $lists = Db::name('pcolumn_'.$db_i)->field('id,title,wid,status')->where('id','not in',$id)->where('status','<',3)->select();
        return $lists;
    }

    //获取商家商品分组信息
    public function product_group_detail($where,$db_i)
    {
        $result = Db::name('pcolumn_'.$db_i)->field('id,cid,title,status')->where($where)->find();
        return $result;
    }


    //查看商户商品信息
    public function product_detail($where,$db_i)
    {
        $result = Db::name('product_'.$db_i)->where($where)->find();
        return $result;
    }

}


